package com.hrsoft.edi.stub;

import cn.hutool.json.JSONObject;
import com.hrsoft.edi.stub.consant.AppInfo;
import com.hrsoft.edi.stub.request.InventoryQueryRequest;
import com.qimen.api.DefaultQimenClient;
import com.qimen.api.QimenClient;
import com.qimen.api.response.InventoryQueryResponse;
import com.taobao.api.ApiException;

import java.util.ArrayList;
import java.util.List;

public class InventoryQueryTest
{

    public static void main(String[] args)
    {
        InventoryQueryRequest inventoryQueryRequest = new InventoryQueryRequest();
        inventoryQueryRequest.setCustomerId(AppInfo.CUSTOMER_ID);
        List<InventoryQueryRequest.Criteria> criteriaList = new ArrayList<>();
        InventoryQueryRequest.Criteria criteria = new InventoryQueryRequest.Criteria();
        criteria.setWarehouseCode(AppInfo.WAREHOUSE_CODE);
        criteria.setItemCode("20191210");
//        criteria.setItemId("190054562177310720");
        criteriaList.add(criteria);

        InventoryQueryRequest.Criteria criteria1 = new InventoryQueryRequest.Criteria();
        criteria1.setWarehouseCode(AppInfo.WAREHOUSE_CODE);
        criteria1.setItemCode("coco");
        criteria1.setItemId("188345788632010752");
        criteriaList.add(criteria1);
        inventoryQueryRequest.setCriteriaList(criteriaList);
        QimenClient client = new DefaultQimenClient(AppInfo.URL, AppInfo.APP_KEY, AppInfo.SECRET);
        try
        {
            InventoryQueryResponse response = client.execute(inventoryQueryRequest);
            System.out.println(new JSONObject(response));
        }
        catch (ApiException e)
        {
            e.printStackTrace();
        }
    }
}
